cc.Class({
	extends: cc.Component,

	properties: {
		realplayer: {
			default: null,
			type: cc.Node
		},
		crush: { //粉碎机
			default: null,
			type: cc.Node
		},
		zz: { //粉碎机
			default: null,
			type: cc.Node
		},
		tl: { //
			default: null,
			type: cc.Node
		},
		qd: { //粉碎机
			default: null,
			type: cc.Node
		},
		jr: { //粉碎机
			default: null,
			type: cc.Node
		},
		fx: { //粉碎机
			default: null,
			type: cc.Node
		},
		zl: { //粉碎机
			default: null,
			type: cc.Node
		},
		nowstep:0,
		slocalPos:null,
		slocalPos2:null,
		tlman: { //粉碎机
			default: null,
			type: cc.Node
		},
		qdman: { //粉碎机
			default: null,
			type: cc.Node
		},
		jrman: { //粉碎机
			default: null,
			type: cc.Node
		},
		tllist: { //粉碎机
			default: null,
			type: cc.Node
		},
		qdlist: { //粉碎机
			default: null,
			type: cc.Node
		},
		fxlist: { //粉碎机
			default: null,
			type: cc.Node
		},
		
	},

	// LIFE-CYCLE CALLBACKS:

	onLoad() {
		// this.m_sc[0].zIndex=1000;
		
		this.tlman.active=false;
		this.qdman.active=false;
		this.qdlist.active=false;
		this.fxlist.active=false;
		this.jrman.active=false;
		
		this.slocalPos = this.getlocal(this.crush,this.node);
		this.slocalPos2 = this.slocalPos;
		this.slocalPos3 = this.getlocal(this.zz,this.node);
		this.slocalPos4 = this.getlocal(this.tl,this.node);
		this.slocalPos5 = this.getlocal(this.qd,this.node);
		this.slocalPos6 = this.getlocal(this.jr,this.node);
		this.slocalPos7 = this.getlocal(this.fx,this.node);
		this.slocalPos8 = this.getlocal(this.zl,this.node);
	
	
	},

	start() {

	},
	getlocal:function(tonode,selfnode){
		var starWorldPos = tonode.convertToWorldSpaceAR(selfnode.position);
		return selfnode.convertToNodeSpaceAR(starWorldPos)
	},

	update(dt) {
		
	 //cc.log(step);
		if (step == 1&&this.nowstep!=1) {
		
			this.nowstep=step;
			//设置相机位置
			this.node.x = this.slocalPos.x;
			this.node.y = this.slocalPos.y;
			//设置人物坐标位置
			this.realplayer.x = this.crush.x;
			this.realplayer.y = this.crush.y;
		 
		} else if (step == 2&&this.nowstep!=2) {
			
			this.nowstep=step;
			//设置相机位置
			this.node.x = this.slocalPos2.x;
			this.node.y = this.slocalPos2.y;
				 
			//设置人物坐标位置
			this.realplayer.x = this.crush.x;
			this.realplayer.y = this.crush.y;

		} else if (step == 3&&this.nowstep!=3) {
			
			this.nowstep=step;
		//	this.slocalPos = this.getlocal(this.crush,this.node);
 		// 	let starWorldPos = this.crush.convertToWorldSpaceAR(this.node.position);
			// let localPos = this.node.convertToNodeSpaceAR(starWorldPos);
		//	cc.log( this.slocalPos);
			//设置相机位置
			this.node.x = this.slocalPos3.x;
			this.node.y = this.slocalPos3.y;
				 
			//设置人物坐标位置
			this.realplayer.x = this.zz.x;
			this.realplayer.y = this.zz.y;

		} else if (step == 4&&this.nowstep!=4) {
			this.tlman.active=true;
			this.qdman.active=false;
			this.nowstep=step;
		//	this.slocalPos = this.getlocal(this.crush,this.node);
 		// 	let starWorldPos = this.crush.convertToWorldSpaceAR(this.node.position);
			// let localPos = this.node.convertToNodeSpaceAR(starWorldPos);
		//	cc.log( this.slocalPos);
			//设置相机位置
			this.node.x = this.slocalPos4.x;
			this.node.y = this.slocalPos4.y;
			
			 
			//设置人物坐标位置
			this.realplayer.x = this.tl.x;
			this.realplayer.y = this.tl.y;

		} else if (step == 5&&this.nowstep!=5) {
			
			//cc.log('1111');
			this.tlman.active=false;
			this.qdman.active=true;
			this.tllist.active=false;
			this.qdlist.active=true;
			
			this.nowstep=step;
		//	this.slocalPos = this.getlocal(this.crush,this.node);
 		// 	let starWorldPos = this.crush.convertToWorldSpaceAR(this.node.position);
			// let localPos = this.node.convertToNodeSpaceAR(starWorldPos);
		//	cc.log( this.slocalPos);
			//设置相机位置
			this.node.x = this.slocalPos5.x;
			this.node.y = this.slocalPos5.y;
				 
			//设置人物坐标位置
			this.realplayer.x = this.qd.x;
			this.realplayer.y = this.qd.y;

		}
		else if (step == 6&&this.nowstep!=6) {
			
			
			this.tlman.active=false;
			this.qdman.active=false;
			this.tllist.active=false;
			this.qdlist.active=true;
			
			
			
			this.jrman.active=true;
			var _self=this;
			
			
			setInterval(function(){
				_self.jrman.active=false;
			}, 20000);
			
			
			// var i=255;
			// setInterval(function(){
			// 	 i--;
			// 	_self.jrman.opacity=i;
			// }, 100);
			
			
			this.fxlist.active=true;
			
		
						
						
			this.nowstep=step;
		//	this.slocalPos = this.getlocal(this.crush,this.node);
		// 	let starWorldPos = this.crush.convertToWorldSpaceAR(this.node.position);
			// let localPos = this.node.convertToNodeSpaceAR(starWorldPos);
		//	cc.log( this.slocalPos);
			//设置相机位置
			this.node.x = this.slocalPos6.x;
			this.node.y = this.slocalPos6.y;
				 
			//设置人物坐标位置
			this.realplayer.x = this.jr.x;
			this.realplayer.y = this.jr.y;
		
		}else if (step == 7&&this.nowstep!=7) {
			
			this.tlman.active=false;
			this.qdman.active=false;
			this.tllist.active=false;
			this.qdlist.active=true;
			this.jrman.active=false;
			this.fxlist.active=true;
			
			
			this.nowstep=step;
		//	this.slocalPos = this.getlocal(this.crush,this.node);
 		// 	let starWorldPos = this.crush.convertToWorldSpaceAR(this.node.position);
			// let localPos = this.node.convertToNodeSpaceAR(starWorldPos);
		//	cc.log( this.slocalPos);
			//设置相机位置
			this.node.x = this.slocalPos7.x;
			this.node.y = this.slocalPos7.y;
				 
			//设置人物坐标位置
			this.realplayer.x = this.fx.x;
			this.realplayer.y = this.fx.y;

		}
		else if (step == 8&&this.nowstep!=8) {
			this.tlman.active=false;
			this.qdman.active=false;
			this.tllist.active=false;
			this.qdlist.active=true;
			this.fxlist.active=true;
			
			this.nowstep=step;
		//	this.slocalPos = this.getlocal(this.crush,this.node);
		// 	let starWorldPos = this.crush.convertToWorldSpaceAR(this.node.position);
			// let localPos = this.node.convertToNodeSpaceAR(starWorldPos);
		//	cc.log( this.slocalPos);
			//设置相机位置
			this.node.x = this.slocalPos8.x;
			this.node.y = this.slocalPos8.y;
				 
			//设置人物坐标位置
			this.realplayer.x = this.zl.x;
			this.realplayer.y = this.zl.y;
		
		}else if (step == 9&&this.nowstep!=9) {
			this.tlman.active=false;
			this.qdman.active=false;
			this.tllist.active=false;
			this.qdlist.active=true;
			this.fxlist.active=true;
			
			this.nowstep=step;
		//	this.slocalPos = this.getlocal(this.crush,this.node);
		// 	let starWorldPos = this.crush.convertToWorldSpaceAR(this.node.position);
			// let localPos = this.node.convertToNodeSpaceAR(starWorldPos);
		//	cc.log( this.slocalPos);
			//设置相机位置
			this.node.x = this.slocalPos8.x;
			this.node.y = this.slocalPos8.y;
				 
			//设置人物坐标位置
			this.realplayer.x = this.zl.x;
			this.realplayer.y = this.zl.y;
		
		}



		//this.node.runAction(cc.follow(this.crush));

	},
});
